﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using diploma.core.data.objects;
using diploma.core;
using diploma.core.localize;

namespace diploma.editor
{
    public partial class ChooseParentForm : Form, ILocalizable
    {
        private long id;
        private AbstractLocalizator localizator;


        public ChooseParentForm(long _id,List<Theme> themes, AbstractLocalizator _localizator)
        {
            InitializeComponent();
            id = _id;
            cbThemesList.Items.AddRange(themes.ToArray());
            if (cbThemesList.Items.Count > 0)
            {
                cbThemesList.SelectedIndex = 0;
            }
            localizator = _localizator;
            Localize();
        }

        private long parent;

        public long Parent 
        {
            get 
            {
                return parent;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void btnChoose_Click(object sender, EventArgs e)
        {
            parent = (cbThemesList.SelectedItem as Theme).Id;
            DialogResult = DialogResult.OK;
            Close();
        }

        #region ILocalizable Members

        public void Localize()
        {
            Text = localizator.GetLocolizeWord(Text);
            btnCancel.Text = localizator.GetLocolizeWord(btnCancel.Text);
            btnChoose.Text = localizator.GetLocolizeWord(btnChoose.Text);
            label1.Text = localizator.GetLocolizeWord(label1.Text);
        }

        #endregion
    }
}
